package com.wanshi.servlet;

import com.wanshi.entity.Product;
import com.wanshi.entity.User;
import com.wanshi.service.ProdService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/seller/findProdByUser")
public class findProdByUser extends HttpServlet {

    private ProdService prodService = new ProdService();

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");

        List<Product> list = prodService.findProdByUser(user.getId());

        request.setAttribute("list",list);
        request.getRequestDispatcher("/seller/page_seller.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}

